/**
 * File: FileMetaStore.java
 * Created by: mhaimel
 * Created on: Jun 16, 2010
 * CVS:  $Id: FileMetaStore.java 1.0 Jun 16, 2010 2:52:40 PM mhaimel Exp $
 */
package uk.ac.ebi.curtain.utils.data.store;

import java.io.File;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;

/**
 * @author mhaimel
 *
 */
public class FileMetaStore extends GenericMetaStore<File> {
	private final AtomicBoolean exist = new AtomicBoolean(false);
	
	public FileMetaStore() {
		this(false);
	}
	
	public FileMetaStore(boolean existancyCheck) {
		this.exist.set(existancyCheck);
	}
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	protected File _stringToType(String string) {
		File file = new File(string);
		if(exist.get() && !file.exists()){
			throw new IllegalArgumentException("File does not Exist: " + file);
		}
		return file;
	}

	@Override
	protected File[] _toArray(List<File> tlist) {
		return tlist.toArray(new File[0]);
	}
}
